<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组翻转</title>

    <script>
        var array = [1, 2, 3, 4, 5];
        var newArray = [array.length];
        var flag = array.length;
        for (var i = 0; i < array.length; i++) {
            newArray[i] = array[flag - 1];
            flag--;
        }
        console.log(array);
        console.log(newArray);
    </script>

</head>

<body>

</body>

</html>